<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'reg.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<style type="text/css">
		#info{
			border:1px solid #000;
			background-color: #ccc;
			font-size: 12px;
		}
	</style>
	<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
	<script type="text/javascript">
	    //document.ready页面结构加载完成执行该function
	    $(function(){
	    	  //单击按钮发送请求
			  $("#btn1").click(function(e) {
                	$.ajax({ 
					   url:"loginJson",
					   type:"POST",
					   data: {uname:$("#uname").val(),upwd:$("#upwd").val()},
					   dataType:"json",
					   success: function(data,status){
							   if(data.uname){
								   $("#login").html("欢迎: "+ data.uname+"登录,<br/>"
										   +"用户编号:"+data.uid+"<br/>"
								           +"用户密码:"+data.upwd+"<br/>");
							   }
					   },
					   error: function(){
						   $("#error").html("用户名或密码错误");
					   }
					});
				
				
               });//单击事件结束
	    	
	    	
	    	
	    });//document.ready结束
	
	
	</script>


  </head>
  
  <body>
    <form action="" name="form1" >
    <div id="error"></div>
    <div id="login">
    用户账号：<input type="text" name="uname" id="uname" ><br/>
  用户密码:  <input type="password" name="upwd" id="upwd"><br/>
  <input type="button" value="登录" id="btn1" >
  </div> 
    </form>
    
    
    
  </body>
</html>
